package thread;

/**
 * 静态方法上使用synchronized 那么该方法一同具有同步效果
 */
public class SyncDemo3 {
    public static void main(String[] args) {
        //Boo b1=new Boo();
        //Boo b2=new Boo();
      //  Thread t1=new Thread(()->b1.doSome());
       // Thread t2=new Thread(()->b2.doSome());
       Thread t1=new Thread(()->Boo.doSome());
      Thread t2=new Thread(()->Boo.doSome());
       t1.start();
       t2.start();

    }
}

class  Boo {
    //public synchronized static void doSome(){
    public static void doSome() {
        synchronized (Boo.class) {
            Thread t = Thread.currentThread();
            System.out.println(t + "正在运用doSome的方法");
            try {
                Thread.sleep(5000);
            } catch (InterruptedException e) {

            }
            System.out.println(t + "运用doSome的方法完毕");
            ;
        }
    }
}